@props([
    'label' => '',
    'name' => '',
    'type' => 'text',
    'placeholder' => '',
    'required' => false,
    'error' => '',
    'icon' => '',
    'iconRight' => '',
    'value' => '',
    'class' => 'input input-bordered w-full'
])

<div class="form-control">
    @if($label)
        <label class="label">
            <span class="label-text font-medium">{{ $label }}</span>
            @if($required)
                <span class="label-text-alt text-error">*</span>
            @endif
        </label>
    @endif
    
    <div class="relative">
        @if($icon)
            {!! $icon !!}
        @endif
        
        <input 
            type="{{ $type }}"
            name="{{ $name }}"
            value="{{ old($name, $value) }}"
            placeholder="{{ $placeholder }}"
            class="{{ $class }} {{ $icon ? 'pl-12' : '' }} {{ $iconRight ? 'pr-12' : '' }} {{ $error ? 'input-error' : '' }}"
            {{ $required ? 'required' : '' }}
            {{ $attributes }}
        >
        
        @if($iconRight)
            {!! $iconRight !!}
        @endif
    </div>
    
    @if($error)
        <label class="label">
            <span class="label-text-alt text-error">{{ $error }}</span>
        </label>
    @endif
    
    @error($name)
        <label class="label">
            <span class="label-text-alt text-error">{{ $message }}</span>
        </label>
    @enderror
</div> 